import Vue from 'vue'
import App from './App'
import filters from "utils/filters" // 过滤器
import regular from '@/utils/regular' // 正则校验
import share from "utils/mixins.js"
import { VueJsonp } from "vue-jsonp"
import { $handleStatistcs } from "@/utils/statistics.js"
Vue.config.productionTip = false

Vue.prototype.$regular = regular // 正则校验
Vue.use(VueJsonp)
Vue.mixin(share)

// 全局过滤器
for (let key in filters) {
    Vue.filter(key, filters[key])
}
// 默认跳转为页面跳转，状态0为tabbar跳转，状态2为后退跳转
Vue.prototype.$handleOpenUrl = function(url,stu=1) {
	
	//0为tabbar跳转
	if(stu==0) {
		uni.switchTab({
			url:url
		})
		return
	}
	//2为返回跳转
	if(stu==2) {
		uni.navigateBack({
			delta:1
		})
		return
	}
	let userId = uni.getStorageSync("userId")
	if(!userId&&stu!=99) {
		uni.navigateTo({
			url: "/pages/login/index",
		})
		$handleStatistcs()
		return;
	}
	if(!url&&stu==1) {
		uni.switchTab({
			url: "/pages/find/index",
		})
		$handleStatistcs()
		return;
	}
	uni.navigateTo({
		url: url,
	})
	$handleStatistcs(url)
}
App.mpType = 'app'

// #ifdef H5
import wechat from './utils/share_h5.js'
if(wechat.isWechat()){
    Vue.prototype.$wechat = wechat;
}

// 客服系统
window._MICHAT = window._MICHAT || function () {
	(_MICHAT.a = _MICHAT.a || []).push(arguments);
};
_MICHAT("accountid", 118991);
_MICHAT("domain", "mad.miduoke.net");
(function (m, d, q, j, s) {
	(j = d.createElement(q)), (s = d.getElementsByTagName(q)[0]);
	j.async = true;
	j.charset = "UTF-8";
	j.src =
		("https:" == document.location.protocol
			? "https://"
			: "http://") +
		"static.miduoke.net/Web/JS/mivisit.js?_=t";
	s.parentNode.insertBefore(j, s);
})(window, document, "script");
// #endif

const app = new Vue({
	...App
})
app.$mount()
